<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html"/>

  <xsl:template match="/">
    <xsl:apply-templates select="/cruisecontrol/build/*[local-name()='TestRun']/*[local-name()='Results']/*[local-name()='LoadTestResult']" />
  </xsl:template>


  <xsl:template match="/cruisecontrol/build/*[local-name()='TestRun']/*[local-name()='Results']/*[local-name()='LoadTestResult']">
    <h2>
      Summary for '<xsl:value-of select="@executionId"/>'
    </h2>
    <xsl:apply-templates select="*[local-name()='Summary']/*[local-name()='TestSummaries']">
    </xsl:apply-templates>

    <h2>
      Transactions
    </h2>
    <xsl:apply-templates select="*[local-name()='Summary']/*[local-name()='TransactionSummaries']">
    </xsl:apply-templates>

  </xsl:template>

  <xsl:template match="*[local-name()='Summary']/*[local-name()='TestSummaries']">
    <table border="1" cellSpacing="0" cellPadding="5" >
      <thead style="text-align: center;">
        <td>Name</td>
        <td>Total</td>
        <td style="background-color: fireBrick; color: white;">Failed</td>
        <td style="background-color: darkblue; color: white;">Duration</td>
      </thead>
      <xsl:apply-templates select="./*" />
    </table>

  </xsl:template>

  <xsl:template match="*[local-name()='TestSummary']">
    <tr>
      <td>
        <xsl:value-of select="@testName"/>
      </td>
      <td>
        <xsl:value-of select="@totalTests"/>
      </td>
      <td>
        <xsl:value-of select="@testsFailed"/>
      </td>
      <td>
        <xsl:value-of select="@averageDuration"/>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="*[local-name()='Summary']/*[local-name()='TransactionSummaries']">
    <table border="1" cellSpacing="0" cellPadding="5" >
      <thead style="text-align: center;">
        <td>Name</td>
        <td>Count</td>
        <td style="background-color: darkblue; color: white;">Elapsed Time</td>
        <td style="background-color: darkblue; color: white;">Response Time</td>
      </thead>
      <xsl:apply-templates select="./*" />
    </table>

  </xsl:template>

  <xsl:template match="*[local-name()='TransactionSummary']">
    <tr>
      <td>
        <xsl:value-of select="@transactionName"/>
      </td>
      <td>
        <xsl:value-of select="@transactionCount"/>
      </td>
      <td>
        <xsl:value-of select="@elapsedTime"/>
      </td>
      <td>
        <xsl:value-of select="@responseTime"/>
      </td>
    </tr>
  </xsl:template>


</xsl:stylesheet>

